//
//  MCRechargeHeaderView.m
//  TLYL
//
//  Created by MC on 2017/6/13.
//  Copyright © 2017年 TLYL01. All rights reserved.
//

#import "MCRechargeHeaderView.h"
#import "UIView+MCParentController.h"
@interface MCRechargeHeaderView ()
/*
 * 充值
 */
@property (nonatomic,strong)UILabel *lab_Recharge;

/*
 * 账户金额
 */
@property (nonatomic,strong)UILabel *lab_money;

/*
 * 账户余额
 */
@property (nonatomic,strong)UILabel *lab_YuE;

/*
 * 返回按钮
 */
@property (nonatomic,strong)UIButton *btn_back;
@end

@implementation MCRechargeHeaderView
- (instancetype)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        [self createUI];
    }
    return self;
}

-(void)createUI{
    
    self.backgroundColor=RGB(74, 166, 235);
    
   

    _lab_Recharge = [[UILabel alloc]init];
    _lab_Recharge.layer.cornerRadius=5;
    _lab_Recharge.backgroundColor = [UIColor clearColor];
    _lab_Recharge.layer.masksToBounds = YES;
    _lab_Recharge.font = [UIFont systemFontOfSize:18];
    _lab_Recharge.numberOfLines=1;
    _lab_Recharge.text = @"充值";
    _lab_Recharge.textColor=[UIColor whiteColor];
    _lab_Recharge.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_lab_Recharge];

    _lab_money = [[UILabel alloc]init];
    _lab_money.layer.cornerRadius=5;
    _lab_money.backgroundColor = [UIColor clearColor];
    _lab_money.layer.masksToBounds = YES;
    _lab_money.textColor=[UIColor whiteColor];
    _lab_money.font = [UIFont systemFontOfSize:30];
    _lab_money.numberOfLines=1;
    _lab_money.text = @"99,999,999.00";
    _lab_money.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_lab_money];
    
    _lab_YuE = [[UILabel alloc]init];
    _lab_YuE.layer.cornerRadius=5;
    _lab_YuE.textColor=[UIColor whiteColor];
    _lab_YuE.backgroundColor = [UIColor clearColor];
    _lab_YuE.layer.masksToBounds = YES;
    _lab_YuE.font = [UIFont systemFontOfSize:15];
    _lab_YuE.numberOfLines=1;
    _lab_YuE.text = @"账户余额(元)";
    _lab_YuE.textAlignment=NSTextAlignmentCenter;
    [self addSubview:_lab_YuE];
    
    [self layOutConstraints];
    
    _btn_back = [[UIButton alloc]init];
    [_btn_back setImage:[UIImage imageNamed:@"图层-6"] forState:UIControlStateNormal];
    //    [button setImage:[UIImage imageNamed:@"图层-6"] forState:UIControlStateHighlighted];
    _btn_back.contentHorizontalAlignment = UIControlContentHorizontalAlignmentLeft;
    _btn_back.contentEdgeInsets = UIEdgeInsetsMake(0, 0, 0, 0);
    [self addSubview:_btn_back];
    _btn_back.frame=CGRectMake(10, 20, 70, 30);
    [_btn_back addTarget:self action:@selector(action_Back) forControlEvents:UIControlEventTouchUpInside];
    

    
}


-(void)layOutConstraints{
    
    [_lab_Recharge mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(self.mas_top).offset(20);
        make.height.mas_equalTo(35);
    }];
    
    [_lab_money mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(_lab_Recharge.mas_bottom).offset(10);
        make.height.mas_equalTo(40);
    }];
    
    [_lab_YuE mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self);
        make.top.equalTo(_lab_money.mas_bottom).offset(10);
        make.height.mas_equalTo(20);
    }];
    
   
}

+(CGFloat)computeHeight:(id)info{
    return 120;
}

-(void)setDataSource:(id)dataSource{
    _dataSource=dataSource;
//    NSString *str_name =@"尊敬的会员：Kaka";
//    NSString *Left_name =@"尊敬的会员：";
//    NSString *str_money=@"您的账户余额：99999元";
//    NSString *Left_money=@"您的账户余额：";
    
    
//    /*
//     * 设置会员 富文本
//     */
//    NSRange range_name = [str_name rangeOfString:Left_name];
//    [self setTextColor:_lab_name FontNumber:[UIFont systemFontOfSize:14] AndRange:range_name AndColor:[UIColor redColor]];
//    
//    /*
//     * 设置账户余额 富文本
//     */
//    NSRange range_money = [str_money rangeOfString:Left_money];
//    [self setTextColor:_lab_money FontNumber:[UIFont systemFontOfSize:14] AndRange:range_money AndColor:[UIColor redColor]];

}
//设置不同字体颜色
-(void)setTextColor:(UILabel *)label FontNumber:(id)font AndRange:(NSRange)range AndColor:(UIColor *)vaColor{
    NSMutableAttributedString *str = [[NSMutableAttributedString alloc] initWithString:label.text];
    //设置字号
    [str addAttribute:NSFontAttributeName value:font range:range];
    //设置文字颜色
    [str addAttribute:NSForegroundColorAttributeName value:vaColor range:range];
    label.attributedText = str;
}

-(void)action_Back{
    [[UIView MCcurrentViewController].navigationController popViewControllerAnimated:YES];
}

@end




























